function ruleRank(str) {
  if (str.length % 2 !== 0) return false;
  const arr = [];
  const addArr = ["(", "[", "{"];
  const minusArr = [")", "]", "}"];
  for (let i = 0; i < str.length; i++) {
    if (addArr.includes(str[i])) {
      arr.push(str[i]);
      continue;
    } else if (
      minusArr.includes(str[i]) &&
      minusArr.indexOf(str[i]) === addArr.indexOf(arr.pop())
    ) {
      continue;
    }
    return false;
  }
  return arr.length === 0;
}
console.log(ruleRank("{{[{]}}}"));
